package com.xintonghua.bussiness.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.SimpleBaseAdapter;
import com.xintonghua.bussiness.bean.CartBean;
import com.xintonghua.bussiness.util.GlideUtils;
import com.xintonghua.bussiness.util.MyUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/3/31.
 * 包名：com.xintonghua.bussiness.adapter
 */

public class SureOrderAdapter extends SimpleBaseAdapter<CartBean> {


    public SureOrderAdapter(List<CartBean> list, Context context) {
        super(list, context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ShopLeftViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.adapter_sure_order, null);
            holder = new ShopLeftViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ShopLeftViewHolder) convertView.getTag();

        }
        final CartBean bean = mList.get(position);
        GlideUtils.load(context, holder.ivShopPic, bean.getDetail_img());
        holder.tvShopName.setText(bean.getName());
        holder.tvShopPrice.setText(MyUtils.getMoney(context, bean.getMoney()));
        holder.tvShopCount.setText("x" + bean.getCount());

        return convertView;
    }


    static class ShopLeftViewHolder {

        @BindView(R.id.iv_shop_pic)
        ImageView ivShopPic;
        @BindView(R.id.tv_shop_name)
        TextView tvShopName;
        @BindView(R.id.tv_shop_price)
        TextView tvShopPrice;
        @BindView(R.id.tv_shop_count)
        TextView tvShopCount;

        public ShopLeftViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
